<script type="text/javascript">
jQuery(document).ready(function(){
							jQuery('.tuan').hide();
							});
jQuery('.plus').live('click',function(){
							root=$('#root').val();
							id =jQuery(this).attr('id');
							sotuan = jQuery('#sotuan'+id).val();
							jQuery(this).attr('src',root+'img/minus.png');
							if(!isNaN(sotuan)){}
							else
								sotuan = 7;
							for (i=1;i<=sotuan;i++)
							{
								jQuery('#tuan'+id+i).show(1000);
							}
							jQuery(this).addClass('minus');
							jQuery(this).attr('class','minus');
							});
jQuery('.minus').live('click',function(){
							root=$('#root').val();
							id =jQuery(this).attr('id');
							sotuan = jQuery('#sotuan'+id).val();
							jQuery(this).attr('src',root+'img/plus.png');
							if(!isNaN(sotuan)){}
							else
								sotuan = 7;
							for (i=1;i<=sotuan;i++)
							{
								jQuery('#tuan'+id+i).hide(1000);
							}
							jQuery(this).attr('class','plus');
							});
</script>
<?php echo  $form->create('Kehoachnvs')?>
<div class="kehoachnvs">
	<h2 style="margin-bottom: 0px;"><?php __('Giao chỉ tiêu của '.$tennvs[0]['nhanviens']['tennv']);?></h2>
	<div style="margin-bottom: 0px;">
	<?php
		echo $form->input('root',array('id'=>'root','type'=>'hidden','value'=>$this->webroot));
		if(empty($nams))
			$nams =array(); 
		echo $form->input('nam',array('id'=>'nam','label'=>'Năm','options'=>$nams,'empty'=>"Chọn Năm",'selected'=>date('Y')));
		?>
	</div>
	<div id='tbltg' style="margin-top: 0px;">
    <h3 style="margin-top: 0px;">Xin vui lòng kiểm tra thời gian bạn muốn lập kế hoạch đã tồn tại hay chưa</h3>
	<table cellpadding="0" cellspacing="0" id="tables">

	<tr>
			<th><?php echo 'STT';?></th>
			<th><?php echo 'Thời Gian';?></th>
			<th class="actions"><?php __('Lựa chọn');?></th>
	</tr>
	<?php
	$i = 0;$sttthang=0;$stttuan=0;
	foreach ($kehoachthangs as $kehoachthang):
		$thanght = date('m',strtotime($kehoachthang['Thoigian']['ngaykt']));
		$class = null;
		$id=null;
		$align =null;
		$khcngay =date('d-m-Y',strtotime($kehoachthang['Thoigian']['ngaykt']))-date('d-m-Y',strtotime($kehoachthang['Thoigian']['ngaybd']));
	/*
		if ($sttthang>0)
			echo $form->input('', array('type'=>'hidden','value'=>$stttuan,'id'=>'sotuan'.$sttthang));
	*/
		$sttthang++;
		
		
		$id = ' id ='.$sttthang;
	?>
	<tr<?php echo $class.$id;?>>
		<td ><?php
		 		if ($khcngay>=8)
		 		{
					echo $sttthang;
		 		} 
		 ?>&nbsp;</td>
		<td <?php echo $align?>>
			<?php
			echo $html->image('/img/plus.png', array('class'=>'plus','id'=>$sttthang));
			 echo '<strong>'.$kehoachthang['Thoigian']['thoigian'].'</strong>'; ?>
		</td>
       
        
		<td class="actions">
			<?php echo $this->Html->link(__('Chỉ tiêu', true), array('controller'=>'chitieukenhs','action' => 'hienchitieu', $kehoachthang['Kehoachnv']['id']));?>
		</td>
		
		
	</tr>
	<?php
			$stttuan=0; 
	foreach ($kehoachtuans as $kehoachtuan):
			$thangoftuan = date('m',strtotime($kehoachtuan['Thoigian']['ngaykt']));
		if($thanght==$thangoftuan)
		{
			$class = null;
			$id=null;
			$align =null;
			$stttuan++;
			$class = ' class = tuan ';
			$id = ' id =tuan'.$sttthang.$stttuan;
			$align = ' align=right';
	?>
	<tr<?php echo $class.$id;?>>
		<td ><?php
		 ?>&nbsp;</td>
		<td <?php echo $align?>>
			<?php echo $kehoachtuan['Thoigian']['thoigian']; ?>
		</td>
       
        
		<td class="actions">
			<?php echo $this->Html->link(__('Chỉ tiêu Tuần', true), array('controller'=>'chitieukenhs','action' => 'hienchitieu', $kehoachtuan['Kehoachnv']['id']));?>
		</td>		
	</tr>
	<?php }
		endforeach; 
		if ($sttthang>0)
			echo $form->input('', array('type'=>'hidden','value'=>$stttuan,'id'=>'sotuan'.$sttthang));
	endforeach; ?>
	</table>
</div>
</div>
<?php
$this->Js->get('#nam')->event('change',
								$this->Js->request(array('controller' => 'kehoachnvs', 'action' => 'laygiaochitieu',$nhanvien_id),
								array('update' => '#tbltg','async' => true,
								'dataExpression' => true,'method' => 'post',
								'data' => $js->serializeForm(array('isForm' => true, 'inline' => true))))); 
echo $form->end();
?>
